# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

proto_library(
    name = "clouderrorreporting_proto",
    srcs = [
        "common.proto",
        "error_group_service.proto",
        "error_stats_service.proto",
        "report_errors_service.proto",
    ],
    deps = [
        "//google/api:annotations_proto",
        "//google/api:monitored_resource_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

proto_library_with_info(
    name = "clouderrorreporting_proto_with_info",
    deps = [
        ":clouderrorreporting_proto",
        "//google/cloud:common_resources_proto",
    ],
)

##############################################################################
# Java
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "java_grpc_library",
    "java_gapic_library",
    "java_gapic_assembly_gradle_pkg",
    "java_proto_library",
    "java_gapic_test",
)

java_proto_library(
    name = "clouderrorreporting_java_proto",
    deps = [":clouderrorreporting_proto"],
)

java_grpc_library(
    name = "clouderrorreporting_java_grpc",
    srcs = [":clouderrorreporting_proto"],
    deps = [":clouderrorreporting_java_proto"],
)

java_gapic_library(
    name = "clouderrorreporting_java_gapic",
    src = ":clouderrorreporting_proto_with_info",
    gapic_yaml = "errorreporting_gapic.yaml",
    service_yaml = "//google/devtools/clouderrorreporting:errorreporting.yaml",
    test_deps = [":clouderrorreporting_java_grpc"],
    deps = [":clouderrorreporting_java_proto"],
)

java_gapic_test(
    name = "clouderrorreporting_java_gapic_test_suite",
    test_classes = [
        "com.google.cloud.errorreporting.v1beta1.ErrorGroupServiceClientTest",
        "com.google.cloud.errorreporting.v1beta1.ErrorStatsServiceClientTest",
        "com.google.cloud.errorreporting.v1beta1.ReportErrorsServiceClientTest",
    ],
    runtime_deps = [":clouderrorreporting_java_gapic_test"],
)

# Opensource Packages
java_gapic_assembly_gradle_pkg(
    name = "google-cloud-error-reporting-v1beta1-java",
    deps = [
        ":clouderrorreporting_java_gapic",
        ":clouderrorreporting_java_grpc",
        ":clouderrorreporting_java_proto",
        ":clouderrorreporting_proto",
    ],
)

##############################################################################
# Go
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "go_proto_library",
    "go_test",
    "go_gapic_library",
    "go_gapic_assembly_pkg",
)

go_proto_library(
    name = "clouderrorreporting_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1",
    protos = [":clouderrorreporting_proto"],
    deps = [
        "//google/api:annotations_go_proto",
        "//google/api:monitoredres_go_proto",
    ],
)

go_gapic_library(
    name = "clouderrorreporting_go_gapic",
    src = ":clouderrorreporting_proto_with_info",
    gapic_yaml = "errorreporting_gapic.yaml",
    importpath = "cloud.google.com/go/errorreporting/apiv1beta1",
    service_yaml = "//google/devtools/clouderrorreporting:errorreporting.yaml",
    deps = [":clouderrorreporting_go_proto"],
)

go_test(
    name = "clouderrorreporting_go_gapic_test",
    srcs = [":clouderrorreporting_go_gapic_srcjar_test"],
    embed = [":clouderrorreporting_go_gapic"],
    importpath = "cloud.google.com/go/errorreporting/apiv1beta1",
)

# Opensource Packages
go_gapic_assembly_pkg(
    name = "gapi-cloud-error-reporting-v1beta1-go",
    deps = [
        ":clouderrorreporting_go_gapic",
        ":clouderrorreporting_go_gapic_srcjar-smoke-test.srcjar",
        ":clouderrorreporting_go_gapic_srcjar-test.srcjar",
        ":clouderrorreporting_go_proto",
    ],
)
